package com.heima.wemedia;

import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;


@SpringBootApplication//启动类
@EnableDiscoveryClient//开启服务发现
@MapperScan("com.heima.wemedia.mapper")//扫描mybatis mapper接口
@EnableFeignClients(basePackages = "com.heima.apis")//开启Feign客户端,指定远程调用接口的包名
@EnableAsync //开启异步调用
@EnableScheduling //开启调度任务
public class WemediaApplication {

    public static void main(String[] args) {
        SpringApplication.run(WemediaApplication.class,args);
    }

    //在自媒体引导类中天mybatis-plus的分页拦截器
    //这段代码的主要功能是创建并配置一个 MyBatis-Plus 拦截器，并注册到 Spring 容器中
    //这个分页拦截器的作用是帮助应用程序在进行数据库查询时，自动实现分页功能
    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor() {
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
        interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
        return interceptor;
    }
}
